home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 September / maximum-cd-2000-09.iso / Vampire the Masquerade / vampire_demo.exe / Codex.nob / TrapCloseRoom.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  4.5 KB  |  137 lines

  1. public class TrapCloseRoom extends Codex {
  2.    private CodexRegion _trapRegion = new CodexRegion(((Codex)this).GetClassThing());
  3.    private CodexThing _rotateDoor1;
  4.    private CodexThing _rotateDoor2;
  5.    private int _numberOfEnemies;
  6.    private String _enemy1Type = "";
  7.    private String _enemy2Type = "";
  8.    private String _enemy3Type = "";
  9.    private String _enemy4Type = "";
  10.    private String _enemy5Type = "";
  11.    private CodexThing _spawn1;
  12.    private CodexThing _spawn2;
  13.    private CodexThing _spawn3;
  14.    private CodexThing _spawn4;
  15.    private CodexThing _spawn5;
  16.    private int _enemiesDead;
  17.    private int initiatorGuid;
  18.    private boolean _bTrapOn = true;
  19.    private boolean _bClosed = true;
  20.    private boolean bSpawned;
  21.    public static String[] _params = new String[]{"Rotate door 1", "Rotate door 2", "Number of enemies needed to kill;5", "Enemy 1 type (template name)", "Enemy 2 type (template name)", "Enemy 3 type (template name)", "Enemy 4 type (template name)", "Enemy 5 type (template name)", "Spawn 1", "Spawn 2", "Spawn 3", "Spawn 4", "Spawn 5"};
  22.  
  23.    public TrapCloseRoom(CodexThing rotateDoor1, CodexThing rotateDoor2, int numberOfEnemies, String enemy1Type, String enemy2Type, String enemy3Type, String enemy4Type, String enemy5Type, CodexThing spawn1, CodexThing spawn2, CodexThing spawn3, CodexThing spawn4, CodexThing spawn5) {
  24.       this._rotateDoor1 = new CodexThing(((Codex)rotateDoor1).GetGUID());
  25.       this._rotateDoor2 = new CodexThing(((Codex)rotateDoor2).GetGUID());
  26.       this._numberOfEnemies = numberOfEnemies;
  27.       this._enemy1Type = enemy1Type;
  28.       this._enemy2Type = enemy2Type;
  29.       this._enemy3Type = enemy3Type;
  30.       this._enemy4Type = enemy4Type;
  31.       this._enemy5Type = enemy5Type;
  32.       this._spawn1 = new CodexThing(((Codex)spawn1).GetGUID());
  33.       this._spawn2 = new CodexThing(((Codex)spawn2).GetGUID());
  34.       this._spawn3 = new CodexThing(((Codex)spawn3).GetGUID());
  35.       this._spawn4 = new CodexThing(((Codex)spawn4).GetGUID());
  36.       this._spawn5 = new CodexThing(((Codex)spawn5).GetGUID());
  37.       ((Codex)this).CaptureThing(this._trapRegion.GetGUID());
  38.       ((Codex)this).CaptureThing(this._rotateDoor1.GetGUID());
  39.       ((Codex)this).CaptureThing(this._rotateDoor2.GetGUID());
  40.       if (this._rotateDoor1.GetDescriptionID().equalsIgnoreCase("PROP")) {
  41.          this._rotateDoor1.SetDescriptionID("GEN_DOOR");
  42.       }
  43.  
  44.       if (this._rotateDoor2.GetDescriptionID().equalsIgnoreCase("PROP")) {
  45.          this._rotateDoor2.SetDescriptionID("GEN_DOOR");
  46.       }
  47.  
  48.    }
  49.  
  50.    public void clicked(int guid, int clickerGuid, int captureID) {
  51.       if (guid == this._rotateDoor1.GetGUID() && this._bTrapOn) {
  52.          if (this._bClosed) {
  53.             this._rotateDoor1.RotatePivot(1, 3.0F);
  54.             this._bClosed = false;
  55.          } else if (!this._bClosed) {
  56.             this._rotateDoor1.RotatePivot(1, -3.0F);
  57.             this._bClosed = true;
  58.          }
  59.       } else {
  60.          new CodexSound("locked_large_02.WAV", 300.0F, 600.0F, 100, 0, 0, guid);
  61.          CodexConsole.PrintNLS(CodexPlayer.GetCurrentPlayer(), 0, "GEN_DOORLOCKED");
  62.       }
  63.  
  64.    }
  65.  
  66.    public void beginscene(int clientGuid, int captureID) {
  67.       if (!this.bSpawned) {
  68.          this._rotateDoor1.SetThingFlags(8192);
  69.          this._rotateDoor2.SetThingFlags(8192);
  70.  
  71.          for(int i = 0; i < this._numberOfEnemies; ++i) {
  72.             switch (i) {
  73.                case 0:
  74.                   ((Codex)this).CaptureThing(this._spawn1.SpawnThing(this._enemy1Type));
  75.                   break;
  76.                case 1:
  77.                   ((Codex)this).CaptureThing(this._spawn2.SpawnThing(this._enemy2Type));
  78.                   break;
  79.                case 2:
  80.                   ((Codex)this).CaptureThing(this._spawn3.SpawnThing(this._enemy3Type));
  81.                   break;
  82.                case 3:
  83.                   ((Codex)this).CaptureThing(this._spawn4.SpawnThing(this._enemy4Type));
  84.                   break;
  85.                case 4:
  86.                   ((Codex)this).CaptureThing(this._spawn5.SpawnThing(this._enemy5Type));
  87.             }
  88.          }
  89.  
  90.          this.bSpawned = true;
  91.       }
  92.    }
  93.  
  94.    public void restore(int flags) {
  95.       this._bTrapOn = CodexSequence.RestoreBoolean();
  96.       this._bClosed = CodexSequence.RestoreBoolean();
  97.       this.bSpawned = CodexSequence.RestoreBoolean();
  98.       this._enemiesDead = CodexSequence.RestoreInt();
  99.       this._numberOfEnemies = CodexSequence.RestoreInt();
  100.    }
  101.  
  102.    public void entered(int guid, int causeGUID, int captureID) {
  103.       if (Codex.IsPlayerGuid(causeGUID) && this._bTrapOn && !this._bClosed) {
  104.          this.initiatorGuid = causeGUID;
  105.          ((Codex)this).CaptureThing(this.initiatorGuid);
  106.          this._rotateDoor1.RotatePivot(1, -1.0F);
  107.          this._bTrapOn = false;
  108.          this._bClosed = true;
  109.          ((Codex)this).SetTimer(45.0F);
  110.       }
  111.    }
  112.  
  113.    public void killed(int guid, int causeID, int captureID) {
  114.       if (guid == this.initiatorGuid || ++this._enemiesDead == this._numberOfEnemies) {
  115.          ((Codex)this).KillAllTimers();
  116.          this._rotateDoor1.RotatePivot(1, 1.0F);
  117.          this._rotateDoor2.RotatePivot(1, 1.0F);
  118.          this._enemiesDead = 10;
  119.       }
  120.  
  121.    }
  122.  
  123.    public void save(int flags) {
  124.       CodexSequence.SaveBoolean(this._bTrapOn);
  125.       CodexSequence.SaveBoolean(this._bClosed);
  126.       CodexSequence.SaveBoolean(this.bSpawned);
  127.       CodexSequence.SaveInt(this._enemiesDead);
  128.       CodexSequence.SaveInt(this._numberOfEnemies);
  129.    }
  130.  
  131.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  132.       this._enemiesDead = 10;
  133.       this._rotateDoor1.RotatePivot(1, 1.0F);
  134.       this._rotateDoor2.RotatePivot(1, 1.0F);
  135.    }
  136. }
  137.